package cn.tedu;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;

public class Demo01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入员工姓名:");
        String name = scanner.nextLine();
        System.out.println("请输入员工工资:");
        int sal = scanner.nextInt();
        try (Connection conn = DBUtil.getConn();)
        {
            String sql = "insert into emp values(null,?,?)";
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setString(1,name);
            ps.setInt(2,sal);
            ps.executeUpdate();
            System.out.println("添加完成");
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
